package bishi.beike;

/**
 * @author: 唐小尊
 * @email: 1171702529@qq.com
 * @cate: 2021/08/13 20:44
 */
public class two {
    public static void main(String[] args) {
        System.out.println(NS_String("ascasdqwedwqdsac",5));
    }
    public static String NS_String(String s, int k) {
        boolean[] b = new boolean[26];
        char c = 'a';
        for (int i=0;i<k;i++){
            while (c<='z'&&s.indexOf(c)<0){
                c++;
            }
            if (c>'z') return "";
            b[c-'a'] = true;
            c++;
        }
        StringBuffer sb = new StringBuffer();
        char[] chars = s.toCharArray();
        for (char aChar : chars) {
            if (!b[aChar - 'a']) sb.append(aChar);
        }
        return sb.toString();
        // write code here
    }
}
